﻿using static XMerp.Controller;

namespace XMerp
{
    public partial class View_CheckProducts : UserControl
    {   
        public  int currentIndex = 0;
        public  List<View_CheckProducts_Products> erpProducts = new();

        public string? platformCode;
        public string? mallCode;
        public string? mallName;
        public string? sysOrderId;
        public string? orderId;
        public string? id;
        public string? cpCode;
        public string? cpCodeTempId;//1535   YTO
        public string? logisticsName;
        public string? subIds;


        public View_CheckProducts()
        {
            InitializeComponent();

            btnRemarks.Click += (o, e) => { CtlFactory("View_CheckProducts_btnRemarks_Click"); };
            btnAdd.Click += (o, e) => { CtlFactory("View_CheckProducts_btnAdd_Click"); };
            btnLess.Click += (o, e) => { CtlFactory("View_CheckProducts_btnLess_Click"); };
        }
        
        public void EndProductRender()
        {
            while(true)
            {
                if (erpProducts.Count - currentIndex > 0)
                {
                    var product = erpProducts[erpProducts.Count - 1];
                    this.pnlContent.Controls.Remove(product);
                    erpProducts.Remove(product);
                    product.Dispose();
                }
                else
                    break;
               
            }
           GC.Collect();
        }
        public void BeginProductRender()
        {
            currentIndex = 0;
            foreach (var item in erpProducts) 
            {
                item.skuId = "";
            }
            labRemarks.Text = "";
            labCheckCount.Text = "0";
        }
    
    }
}
